package com.kmust.dream.wanderingdream.donation.dao;

import com.kmust.dream.wanderingdream.comm.pojo.User;
import com.kmust.dream.wanderingdream.donation.entity.BasicInformationDonationEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.catalina.LifecycleState;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 
 * 
 * @author Leng
 * @email Leng81605@gmail.com
 * @date 2021-07-12 21:35:52
 */
@Mapper
public interface BasicInformationDonationDao extends BaseMapper<BasicInformationDonationEntity> {

    @Select("select username,nickname,mobile,email,url from user WHERE username =  \n" +
            "     (SELECT username FROM recipient_user_union WHERE recipient_user_union.recipient_id = #{recipient_id})")
    User getUserInfo(String recipient_id);
    @Select("SELECT * FROM  basic_information_donation WHERE recipient_id IN (SELECT recipient_id FROM recipient_user_union WHERE username =#{username})")
    List<BasicInformationDonationEntity> getListByUserName(String username);


    @Select("SELECT * FROM `basic_information_donation` where learning_section like concat('%',#{school},'%') limit #{curr},6")
    List<BasicInformationDonationEntity> getListByType(String school,int curr);

    @Select("SELECT * FROM `basic_information_donation` where  learning_section= #{type}")
    List<BasicInformationDonationEntity> getPage(String type);

    /**
     * 1.根据username查询出他的reid
     * 2.根据reid查询出basiclist
     * */
    @Select("SELECT * FROM basic_information_donation WHERE recipient_id in (\n" +
            "   SELECT  recipient_id\tFROM  recipient_user_union WHERE username =#{username} \n" +
            ")")
    List<BasicInformationDonationEntity> getBasicListByUserName(String username);



	
}
